package com.JobFind.controller;

import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.JobFind.DTO.CompanyDTO;
import com.JobFind.DTO.DeliverDTO;
import com.JobFind.DTO.UserDTO;
import com.JobFind.logic.IDeliverLogic;


public class DeliverController extends BaseAction {

	private static final long serialVersionUID = 1L;
	private CompanyDTO companyDTO;
	private DeliverDTO deliverDTO;
	private UserDTO userDTO;
	@Resource
	private IDeliverLogic deliverLogic;
	
	public DeliverDTO getDeliverDTO() {
		return deliverDTO;
	}

	public void setDeliverDTO(DeliverDTO deliverDTO) {
		this.deliverDTO = deliverDTO;
	}

	public CompanyDTO getCompanyDTO() {
		return companyDTO;
	}

	public void setCompanyDTO(CompanyDTO companyDTO) {
		this.companyDTO = companyDTO;
	}

	public UserDTO getUserDTO() {
		return userDTO;
	}

	public void setUserDTO(UserDTO userDTO) {
		this.userDTO = userDTO;
	}

	public void adDeliver() throws Exception{
		PrintWriter out = getWriter();
		try {
			out.println(this.deliverLogic.adDeliver(deliverDTO.getRecruitmentId(),userDTO.getUserId()));
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			out.flush();
			out.close();
		}
	}
	
	public void getResumeList() throws Exception{
		PrintWriter out = getWriter();
		try {
			out.println(this.deliverLogic.getResumeList(companyDTO.getCompanyId()));
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			out.flush();
			out.close();
		}
	}
	
	public void getPassRersonList() throws Exception{
		PrintWriter out = getWriter();
		try {
			out.println(this.deliverLogic.getPassRersonList(companyDTO.getCompanyId()));
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			out.flush();
			out.close();
		}
	}
	
	public void upDeliver() throws Exception{
		PrintWriter out = getWriter();
		try {
			out.println(this.deliverLogic.upDeliver(deliverDTO.getUserId(),deliverDTO.getDeliverId(), deliverDTO.getDeliverStatus(),deliverDTO.getRecruitmentId()));
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			out.flush();
			out.close();
		}
	}
	
	public void getResumeResult() throws Exception{
		PrintWriter out = getWriter();
		try {
			
			out.println(this.deliverLogic.getResumeResult(userDTO.getUserId()));
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			out.flush();
			out.close();
		}
	}
}
